﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RBOSS.Business.Checkout;
using RBOSS.Business.Presenters;
using RBOSS.Business.Views;
using RBOSS.WebUI.Models;

namespace RBOSS.WebUI
{
    public partial class ShippingInformation : MasterSite, IShippingView
    {
        private ShippingPresenter _shippingPresenter;


        protected void Page_Load(object sender, EventArgs e)
        {
            _shippingPresenter = new ShippingPresenter(this);
            if (!Page.IsPostBack)
            {
                _shippingPresenter.PopulateInformation();
            }
            WireupEvent();
        }

        private void WireupEvent()
        {
            butNext.Click += NextClick;
            chkShippingAddress.CheckedChanged += CopyAddressCheckChange;
        }

        private void CopyAddressCheckChange(object sender, EventArgs e)
        {
            _shippingPresenter.CopyBillingAddress();
        }

        private void NextClick(object sender, EventArgs e)
        {
            _shippingPresenter.SaveBillingInformation();
            Response.Redirect("CheckoutForm.aspx");
        }

        public void ShowEmail(bool value)
        {
            txbEmail.Visible = value;
            lblEmail.Visible = value;
        }

        public string Email
        {
            get { return txbEmail.Text; }
            set { txbEmail.Text = value; }
        }

        public string FullName
        {
            get { return txbName.Text; }
            set { txbName.Text = value; }
        }

        public string Address1
        {
            get { return txbAddress1.Text; }
            set { txbAddress1.Text = value; }
        }

        public string Address2
        {
            get { return txbAddress2.Text; }
            set { txbAddress2.Text = value; }
        }

        public string City
        {
            get { return txbCity.Text; }
            set { txbCity.Text = value; }
        }

        public string State
        {
            get { return txbState.Text; }
            set { txbState.Text = value; }
        }

        public string Zip
        {
            get { return txbZip.Text; }
            set { txbZip.Text = value; }
        }

        public string Country
        {
            get { return txbCountry.Text; }
            set { txbCountry.Text = value; }
        }

        public string PhoneNumber
        {
            get { return txbPhoneNumber.Text; }
            set { txbPhoneNumber.Text = value; }
        }
    }
}